import { createWebHashHistory, createRouter } from 'vue-router'
import Home from './views/Home.vue'
import Doc from './views/Doc.vue'
import SwitchDemo from './components/SwitchComponents/SwitchDemo.vue'
import DialogDemo from './components/DialogComponents/DialogDemo.vue'
import ButtonDemo from './components/ButtonComponents/ButtonDemo.vue'
import TabsDemo from './components/TabsComponents/TabsDemo.vue'
import IconDemo from './components/IconComponents/IconDemo.vue'
import DropdownDemo from './components/DropdownComponents/DropdownDemo.vue'

import { h } from 'vue'// 引入h
import Markdown from "./components/Markdown.vue";  // 如果不引入这个，用全局注册的，下面h中的Markdown需要变为'Markdown'
const history = createWebHashHistory()
// const markdown = path => h(Markdown, {path, key: path})
import intro from './markdown/intro.md'
import install from './markdown/Install.md'
import getStarted from './markdown/GetStarted.md'
 const markdown = string => h(Markdown, {content:string , key: string }) // path为一个字符串，不再是路径
// const markdown = fileName => h(Markdown, {path:`../markdown/${fileName}.md`, key: fileName})

export const router = createRouter({
  history: history,
  routes: [
    {path: '/', component: Home},
    {path: '/doc',
      component: Doc,
      children: [
        { path: '', redirect: '/doc/intro'},
        { path: 'intro', component: markdown(intro)},
        { path: 'install', component: markdown(install)},
        { path: 'getStarted', component: markdown(getStarted)},
        { path: 'dialog', component: DialogDemo},
        { path: 'switch', component: SwitchDemo},
        { path: 'button', component: ButtonDemo},
        { path: 'tabs', component: TabsDemo},
        { path: 'icon', component: IconDemo},
        { path: 'dropdown', component: DropdownDemo},
      ]
    }
   ]
})
